package com.songlanyun.modules.exception;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public enum BillException implements IntegerEnum<Integer> {


    VERIFY_STATUS_NOT_NULL(31001, "审核状态不能为空"),
    WITHDRAW_RECORD_NOT_EXIST(31002, "提现记录不存在"),
    PAY_MODE_NOT_EXIST(31003, "支付方式不能为空"),
    VERIFY_PASS(31004, "审核通过才能操作"),
    PARAMETERS_INCOMPLETE(31005, "请求参数不完整"),
    AMOUNT_OUT_OF_SCOPE(31006, "分销提现金额不在规定范围内"),
    THE_WITHDRAWAL_IS_NOT_PENDING(31007, "该提现不是待审核"),

    ;

    private Integer code;
    private String msg;

    BillException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @JsonCreator
    public static BillException getByCode(int code) {
        for (BillException value : BillException.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
